<!DOCTYPE HTML>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<meta charset="utf-8">
<head th:include="include :: header"></head>
<body class="gray-bg">
    <div class="container-div">
		<div class="btn-group hidden-xs" id="toolbar" role="group">
			<a class="btn btn-outline btn-success btn-rounded" onclick="$.operate.add()" shiro:hasPermission="ebox:boxinfoDoor:add">
				<i class="fa fa-plus"></i> 新增
			</a>
			<a class="btn btn-outline btn-danger btn-rounded" onclick="$.operate.batRemove()" shiro:hasPermission="ebox:boxinfoDoor:remove">
				<i class="fa fa-trash-o"></i> 删除
			</a>
			
			<a class="btn btn-outline btn-danger btn-rounded" onclick="pldoortype('1')" >
				<i class="fa"></i> 微
			</a>
			<a class="btn btn-outline btn-danger btn-rounded" onclick="pldoortype('2')" >
				<i class="fa"></i> 小
			</a>
			<a class="btn btn-outline btn-danger btn-rounded" onclick="pldoortype('3')" >
				<i class="fa"></i> 中
			</a>
			<a class="btn btn-outline btn-danger btn-rounded" onclick="pldoortype('4')" >
				<i class="fa"></i> 大
			</a>
			<a class="btn btn-outline btn-danger btn-rounded" onclick="pldoormf('1')" >
				<i class="fa"></i> 设置免费
			</a>
			<a class="btn btn-outline btn-danger btn-rounded" onclick="pldoormf('2')" >
				<i class="fa"></i> 设置收费
			</a>
		</div>
		<form id="boxinfoDoor-form">
		
		<input type="hidden" id="boxGuid" th:value="*{boxguid}" name="boxGuid">
		</form>	
		<div class="col-sm-12 select-info table-striped">
			<table id="bootstrap-table" data-mobile-responsive="true"></table>
		</div>
    </div>
    <div th:include="include :: footer"></div>
    <script th:inline="javascript">
        var editFlag = [[${@permission.hasPermi('ebox:boxinfoDoor:edit')}]];
        var removeFlag = [[${@permission.hasPermi('ebox:boxinfoDoor:remove')}]];
        var prefix = ctx + "ebox/boxinfoDoor"

        $(function() {
        	var boxguid=$("#boxGuid").val();
            	 var options = {
        	            id: "doorGuid",
        	            url: prefix + "/list?boxguid="+boxguid,
        	            createUrl: prefix + "/add?boxguid="+boxguid,
        	            updateUrl: prefix + "/edit/{id}",
        	            removeUrl: prefix + "/remove",
        	            modalName: "快递柜柜门",
        	             columns: [{
        	                checkbox: true
        	            },
        	                {
        	                    field: 'doorName',
        	                    title: '名称'
        	                },
        	                {
        	                    field: 'doorStatus',
        	                    title: '柜门状态',
        	                    sortable: true,
        	                    formatter: function (value, row, index) {
        	                        if (value == '0') {
        	                            return "<span class=\"label label-success\">空闲</span>";
        	                        }
        	                        if (value == '1') {
        	                            return "<span class=\"label label-danger\">占用</span>";
        	                        }
        	                        if (value == '2') {
        	                            return "<span class=\"label label-warning\">打开</span>";
        	                        }
        	                        if (value == '5') {
        	                            return "<span class=\"label label-red\">出错</span>";
        	                        }
        	                    }
        	                },
        	                {
        	                    field: 'doorFz',
        	                    title: '分组'
        	                },
        	                {
        	                    field: 'doorBh',
        	                    title: '编号'
        	                },
        	                {
        	                    field: 'doorType',
        	                    title: '类型',
        	                    sortable: true,
        	                    formatter: function (value, row, index) {
        	                        if (value == '1') {
        	                            return "<span class=\"label\">微小</span>";
        	                        }
        	                        if (value == '2') {
        	                            return "<span class=\"label\">小</span>";
        	                        }
        	                        if (value == '3') {
        	                            return "<span class=\"label\">中</span>";
        	                        }
        	                        if (value == '4') {
        	                            return "<span class=\"label\">大</span>";
        	                        }
        	                    }
        	                },
        	                {
        	                    field: 'doorSfje',
        	                    title: '收费金额'
        	                },
        	                {
        	                    field: 'doorZt',
        	                    title: '状态',
        	                    formatter: function (value, row, index) {
        	                        if (value == '1') {
        	                            return "<span class=\"label label-success\">可用</span>";
        	                        }
        	                        if (value == '0') {
        	                            return "<span class=\"label label-danger\">停用</span>";
        	                        }
        	                    }
        	                },
        	                {
        	                    title: '操作',
        	                    align: 'center',
        	                    formatter: function (value, row, index) {
        	                        var actions = [];
        	                        actions.push('<a class="btn btn-success btn-xs " href="#" onclick="$.operate.edit(\'' + row.doorGuid + '\')"><i class="fa fa-edit"></i>编辑</a> ');
        	                        actions.push('<a class="btn btn-success btn-xs " href="#" onclick="doortype(\'' + row.doorGuid + '\',\'1\');"><i class="fa "></i>微</a> ');
        	                        actions.push('<a class="btn btn-success btn-xs " href="#" onclick="doortype(\'' + row.doorGuid + '\',\'2\');"><i class="fa "></i>小</a> ');
        	                        actions.push('<a class="btn btn-success btn-xs " href="#" onclick="doortype(\'' + row.doorGuid + '\',\'3\');"><i class="fa "></i>中</a> ');
        	                        actions.push('<a class="btn btn-success btn-xs " href="#" onclick="doortype(\'' + row.doorGuid + '\',\'4\');"><i class="fa "></i>大</a> ');
        	                        actions.push('<a class="btn btn-success btn-xs " href="#" onclick="tfrzAdd(\'' + row.doorGuid + '\');"><i class="fa "></i>投放日志</a> ');
        	                        return actions.join('');
        	                    }
        	                }]
        	        };
        	        $.table.init(options);
        });
        
        function pldoortype(doorsize){
        	
        	    var rows = $.common.isEmpty($.table._option.id) ? $.table.selectFirstColumns() : $.table.selectColumns($.table._option.id);
        		if (rows.length == 0) {
        			$.modal.alertWarning("请至少选择一条记录");
        			return;
        		}
        		 $.modal.loading("正在处理中，请稍后...");
                 var config = {
                     url: prefix + "/updatedoortype?doorguid="+rows+"&doorsize="+doorsize,
                     type: "post",
                     dataType: "json",
                     success: function (result) {
                         $.operate.ajaxSuccess(result);
                        }
                 };
                 $.ajax(config) 
        }
        
        function pldoormf(lx){
        	
        	var str="您确认要设置为免费吗？";
        	if(lx=="2"){
        		str="您确认要设置为收费吗？";
        	}
        	var boxguid=$("#boxGuid").val();
        	$.modal.confirm(str, function() {
        		$.modal.loading("正在处理中，请稍后...");
                var config = {
                    url: prefix + "/updatedoorsfje?boxguid="+boxguid+"&sflx="+lx,
                    type: "post",
                    dataType: "json",
                    success: function (result) {
                        $.operate.ajaxSuccess(result);
                       }
                };
                $.ajax(config) 
    		});
    		 
    }
        function doortype(doorguid,doorsize) {
            $.modal.loading("正在处理中，请稍后...");
            var config = {
                url: prefix + "/updatedoortype?doorguid="+doorguid+"&doorsize="+doorsize,
                type: "post",
                dataType: "json",
                success: function (result) {
                    $.operate.ajaxSuccess(result);
                   }
            };
            $.ajax(config) 
          }
        function tfrzAdd(doorguid) {
            var url = ctx + "ebox/clog?doorguid="+doorguid;
            $.modal.openFull("投放日志", url);
            //  $.table.refresh();
        }
    </script>
</body>
</html>
